<html>
<head>
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="http://www.12301.cc/js/echarts-2.2.1/build/dist/echarts-all.js"></script>
	<script language="javascript" src="js/index.js"></script>
	<script type="text/javascript" src="js/moment.min.js"></script>
	<script type="text/javascript" src="js/stay.js"></script>
	<script type="text/javascript" src="js/paystatus.js"></script>
</head>
<body>
	<div style="width:80%;height:80%;" id="main"></div>

	<script type="text/javascript">
		var number_format = function(num) {
	        var result = [ ], counter = 0;
	        num = (num || 0).toString().split('');
	        for (var i = num.length - 1; i >= 0; i--) {
	            counter++;
	            result.unshift(num[i]);
	            if (!(counter % 3) && i != 0) { result.unshift(','); }
	        }
	        return result.join('');
    	}


	    var loadData = function(start_time, past, type) {
	        $.ajax({
	            url : "http://www.12301.cc/module/wxh/monthly/sale_api.html",
	            type : "POST",
	            dataType : "json",
	            data : {
	                start_time : start_time,
	                past : past,
	                type : type
	            },beforeSend:function()
	            {
	                $(".payLoadImg").css("display","inline-block");
	            },success:function(result) {
	                if (result.date.length <= 0) {
	                    alert('此时间段内无数据返回');
	                    return;
	                }
	                var myChart = echarts.init(document.getElementById('main'));
	                
	                var option = {
	                    legend: {                                   // 图例配置
	                        padding: 5,                             // 图例内边距，单位px，默认上下左右内边距为5
	                        itemGap: 5,                            // Legend各个item之间的间隔，横向布局时为水平间隔，纵向布局时为纵向间隔
	                        data: ['当前', '同比', '环比'],
	                    },
	                    tooltip: {                                  // 气泡提示配置
	                        trigger: 'axis',                     // 触发类型，默认数据触发，可选为：'axis'
	                        formatter: function (params,ticket,callback) {
	                            var res = '';
	                            for (var i = 0, l = params.length; i < l; i++) {
	                                res += '<br/>' + params[i].seriesName + ' : ' + number_format(params[i].value);
	                            }
	                            return res;
	                        }
	                    },
	                    toolbox: {
	                        show : true,
	                        feature : {
	                            dataView : {show: true},
	                            magicType : {show: true, type: ['line', 'bar']},
	                            restore : {show: true},
	                            saveAsImage : {show: true}
	                        }
	                    },
	                    xAxis: [                                    // 直角坐标系中横轴数组
	                        {
	                            type: 'category',                   // 坐标轴类型，横轴默认为类目轴，数值轴则参考yAxis说明
	                            data: result.date
	                        }
	                    ],
	                    yAxis: [                                    // 直角坐标系中纵轴数组
	                        {
	                            type: 'value',                      // 坐标轴类型，纵轴默认为数值轴，类目轴则参考xAxis说明
	                            boundaryGap: [0, 0],            // 坐标轴两端空白策略，数组内数值代表百分比
	                            splitNumber: 10                     // 数值轴用，分割段数，默认为5
	                        }
	                    ],
	                    series: [
	                        {
	                            name: '当前',                        // 系列名称
	                            type: 'line',                       // 图表类型，折线图line、散点图scatter、柱状图bar、饼图pie、雷达图radar
	                            data: result.cur,

	                        },
	                        {
	                            name: '同比',                    
	                            type: 'line',                       
	                            data: result.tongbi,
	                            itemStyle : {
	                                'normal' : {
	                                    'lineStyle' : {
	                                        'color' : '#62A3C3',
	                                        'type' : 'dotted'
	                                    }
	                                }  
	                            }
	                        },
	                        {
	                            name: '环比',                    
	                            type: 'line',                       
	                            data: result.huanbi,
	                            itemStyle : {
	                                'normal' : {
	                                    'lineStyle' : {
	                                        'color' : '#D4AE67',
	                                        'type' : 'dotted'
	                                    }
	                                }  
	                            }
	                        },
	                    ]
	                };
	                myChart.setOption(option);
	                myChart.setTheme('macarons');
	            },
	            complete:function()
	            {
	                $(".payLoadImg").fadeOut("slow");
	            }
	        })

    	}
		loadData(0, 'seven', 'order')
	</script>
</body>
</html>